package com.vegetable.modules.entity.stock;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 成本分摊记录表
 * 记录库存与分摊信息的关联关系，用于在其他因素介入时能够根据历史分摊信息正确计算当前的成本价格
 * </p>
 *
 * @author Qwen
 * @since 2025-10-17
 */
@Data
@TableName("cost_allocation_record")
@ApiModel(value = "成本分摊记录", description = "记录库存与分摊信息的关联关系")
public class CostAllocationRecord {

    @ApiModelProperty(value = "主键ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "原始库存ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long originalStockId;

    @ApiModelProperty(value = "分摊后新创建的库存ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long allocatedStockId;

    @ApiModelProperty(value = "分摊批次号")
    private String allocationBatchNo;

    @ApiModelProperty(value = "分摊总成本")
    private BigDecimal totalCost;

    @ApiModelProperty(value = "分摊前成本单价")
    private BigDecimal beforeCostWeight;

    @ApiModelProperty(value = "分摊后成本单价")
    private BigDecimal afterCostWeight;

    @ApiModelProperty(value = "库存重量")
    private BigDecimal weight;

    @ApiModelProperty(value = "单位重量成本")
    private BigDecimal unitCost;

    @ApiModelProperty(value = "操作人ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long operatorId;

    @ApiModelProperty(value = "操作人名称")
    private String operatorName;

    @ApiModelProperty(value = "分摊说明")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
}